import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  EngineerQuery,
  EngineerType,
  EngineerTypePageResult,
  ReviewQuery,
  EngineerOrderQuery, EngineerOrderListResult, EngineerWithdrawQuery
} from "@/api/engineer/types";
import { ServiceTypePageResult } from "@/api/service-type/types";
import {WithdrawalPageResult} from "@/api/system/withdrawal/types";

/**
 * 获取用户分页列表
 *
 * @param queryParams
 */
export function listEngineerPages(
  queryParams: EngineerQuery
): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualEngineer/pages',
    method: 'get',
    params: queryParams,
  });
}

export function engineerAdd(data: any): AxiosPromise<ServiceTypePageResult> {
  return request({
    url: '/web/casualEngineer/add',
    method: 'post',
    data: data,
  });
}

export function engineerUpdate(data: any): AxiosPromise<ServiceTypePageResult> {
  return request({
    url: '/web/casualEngineer/edit',
    method: 'post',
    data: data,
  });
}

export function freezeEdit(data: any): AxiosPromise<any> {
  return request({
    url: '/web/casualEngineer/freezeEdit',
    method: 'post',
    data: data,
  });
}

export function engineerImport(data: any) {
  const formData = new FormData();
  formData.append('file', data.file);
  return request({
    url: '/web/casualEngineer/engineerImport',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}

export function getEngineerForm(id: number): AxiosPromise<EngineerType> {
  return request({
    url: '/web/casualServiceType/queryById',
    method: 'get',
    params: { id: id }
  });
}
//审核用户查询
export function engineerShPages(queryParams: EngineerQuery): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualEngineer/shPages',
    method: 'get',
    params: queryParams,
  });
}
//订单报表
export function orderReport(queryParams: EngineerQuery): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualOrder/orderReport',
    method: 'post',
    data: queryParams,
  });
}
//用户报表
export function engineerReport(queryParams: EngineerQuery): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualOrder/engineerReport',
    method: 'post',
    data: queryParams,
  });
}
///用户审核通过
export function casualEngineerAdopt(id: number): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualEngineer/adopt',
    method: 'get',
    params: {id:id},
  });
}
///用户审核驳回
export function casualEngineerReject(id: number): AxiosPromise<EngineerTypePageResult> {
  return request({
    url: '/web/casualEngineer/reject',
    method: 'get',
    params: {id:id},
  });
}
//用户证件审核列表
export function getreviewList(queryParams:ReviewQuery):AxiosPromise<EngineerTypePageResult>{
  return request({
    url: '/web/casualEngineer/certificatePages',
    method: 'get',
    params:queryParams,
  });
}
//状态字典
export function getdict(){
  return request({
    url:'/web/casualEngineer/certificateOptions',
    method:'get'
  })
}
// 标签
export function getlabeloptions(){
  return request({
    url:'/web/casualServiceType/labeloptions',
    method:'get'
  })
}
// 用户审核
export function passoption(params:any){
  return request({
    url:'/web/casualEngineer/adoptCertificate',
    method:'get',
    params:params
  })
}

// 用户勃回
export function fail(id:number) {
  return request({
    url:'/web/casualEngineer/rejectCertificate',
    method:'get',
    params:{id:id}
  })
}


/**
 * 任务订单信息
 *
 * @param queryParams
 */
export function getEngineerOrderList(queryParams?: EngineerOrderQuery): AxiosPromise<EngineerOrderListResult> {
  return request({
    url: '/web/casualEngineer/engineerOrderList',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 用户提现列表
 *
 * @param queryParams
 */
export function getEngineerWithdrawList(queryParams?: EngineerWithdrawQuery): AxiosPromise<WithdrawalPageResult> {
  return request({
    url: '/web/casualEngineer/engineerWithdrawList',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 用户邀请列表
 *
 * @param queryParams
 */
export function getEngineerInviteList(queryParams?: EngineerOrderQuery): AxiosPromise<EngineerOrderListResult> {
  return request({
    url: '/web/casualEngineer/engineerInviteList',
    method: 'get',
    params: queryParams,
  });
}


/**
 * 工程师邀请订单导出
 *
 * @param queryParams
 * @returns
 */
export function engineerInviteListExport(queryParams: any) {
  return request({
    url: '/web/casualEngineer/engineerInviteListExport',
    method: 'get',
    params: queryParams,
    responseType: 'arraybuffer',
  });
}

/**
 * 总余额和提现中余额数量
 *
 * @param queryParams
 */
export function getOverallBalance(): AxiosPromise<any> {
  return request({
    url: '/web/casualEngineer/overall_balance',
    method: 'get'
  });
}

// 提现时间设置
export function timeAllocation(data:any) {
  return request({
    url: '/engineerEnd/timeAllocation',
    method: 'post',
    data: data
  });
}


